<?php

include './function/Pengguna.php';
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
session_start();
$pengguna = new Pengguna();
if ($_POST['emailUser'] == '') {
    $_SESSION['cekMasuk']['emailUser'] = "email tidak boleh kosong.";
}
if ($_POST['passwordUser'] == '') {
    $_SESSION['cekMasuk']['passwordUser'] = "password tidak boleh kosong.";
}

if (isset($_SESSION['cekMasuk'])) {
    header("Location: masuk.php");
    $_SESSION['cekMasuk']['status'] = "login gagal";
    exit();
} else {
    if ($pengguna->checkLogInPengguna($_POST['emailUser'], $_POST['passwordUser']) == 'sukses') {
        header("Location: pageUser.php");
        $_SESSION['user']['status'] = $_POST['emailUser'];
        exit;
    } else {
        header("Location: masuk.php");
        $_SESSION['cekMasuk']['status'] = "login gagal, email atau password yang anda masukan salah";
        exit();
    }
}